package importadodebookworm;


import java.util.LinkedList;

import excecoes.NaoConseguiuObterResenhasDaRevishException;




/**
 * each class who wants to access book reviews data or book history data 
 * will do it through this class. It grants a single structure for book data
 * access. 
 * this class is a Facade for all access of book reviews data/ user reading history
 *  through revish's API/text file. 
 */
public class AccessBooksData implements InterfaceAccessBooksData
{
	/**
	 * single instance of AccessBooksdata, after all it's a facade and
	 * usually a facade is a singleton to ensure single interface of access.
	 */
	private static AccessBooksData singleInstance;
	
	private InterfaceGetBookReviewData getsBookReviewData;
	
	private AccessBooksData()
	{
		
		getsBookReviewData = new GetReviewDataFromApi();
			
	}
	
	public static synchronized AccessBooksData getAccessBooksData()
	{
		if(singleInstance == null)
		{
			singleInstance = new AccessBooksData();
		}
		
		return singleInstance;
	}
	
	
	
	/**
	 * based on search arguments(like reviewer name, book title etc.) and their
	 * respective arguments values(like reviewer "jaemi", "twilight", etc.), it
	 * returns reviews found in search. It's different from method GetBookReviewsFromRevishAPI
	 * because it returns all reviews from search(not just 20 results at maximum). 
	 * @param searchArguments the arguments to use in the API search for book reviews. Possible values are
	 * "user", "tag", "isbn", "title", "author" and "publisher"
	 * @param argumentsValue the respective arguments' values. 
	 * @return a list of reviews which were found in search
	 */
	public LinkedList<Review> getAllBookReviewsFromRevishAPI(LinkedList<String> searchArguments, LinkedList<String> argumentsValue) throws NaoConseguiuObterResenhasDaRevishException
	{
		return this.getsBookReviewData.getAllBookReviewsFromRevishAPI(searchArguments, argumentsValue);
	}
	
	
	
	/**
	 * basically, the same as getAllBookReviewsFromRevishAPI, but only returns 20 reviews at a maximum. It's for quick searches.
	 * @param searchArguments the arguments to use in the API search for book reviews. Possible values are
	 * "user", "tag", "isbn", "title", "author" and "publisher"
	 * @param argumentsValue the respective arguments' values. 
	 * @return a list of reviews(20 at maximum) which were found in search
	 */
	public LinkedList<Review> getBookReviewsFromRevishAPI(LinkedList<String> searchArguments, LinkedList<String> argumentsValue) throws NaoConseguiuObterResenhasDaRevishException
	{
		return this.getsBookReviewData.getBookReviewsFromRevishAPI(searchArguments, argumentsValue);
	}
	
	
	
	
	
}
